package sg.techstudio.suntec.serialize;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

public class CustomJsonDateSerializer extends JsonSerializer<Date> {
	public static final DateFormat JSON_DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
	
	@Override
	public void serialize(Date value, JsonGenerator gen, SerializerProvider prov)
			throws IOException, JsonProcessingException {
		gen.writeString(JSON_DATEFORMAT.format(value));
	}

}
